﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BarrierGenarator.Net;

namespace BarrierGenarator
{
    public partial class Frm_Upload : Form
    {
        string json;
        public Frm_Upload()
        {
            InitializeComponent();
        }

        public Frm_Upload(string json,string username)
        {
            InitializeComponent();
            this.json = json;
            Text = username;
            tbx_author.Text = Text;
            tbx_author.ReadOnly = true;
        }

        private void btn_up_Click(object sender, EventArgs e)
        {
            if(tbx_name.Text==""||tbx_author.Text=="")
            {
                MessageBox.Show("关卡名和作者名不能为空");
            }
            else
            {
                var result = HttpRequest.Upload_BarrierJson(Text+"`s "+tbx_name.Text, Text, tkb_dif.Value, json);
                if(result=="OK")
                {
                    MessageBox.Show("上传成功");
                    Close();
                }
                else
                {
                    MessageBox.Show(result);
                }
            }
        }
    }
}
